﻿<%@ Page Language="C#" MasterPageFile="../main.master" Inherits="VioletDevelopmentLaboratory.Net.Web.Configuration.VWebConfigManagerPage" %>

<script runat="server">
	protected void HttpHandlersGridView_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
	{
		HttpHandlersDetailsView.ChangeMode(DetailsViewMode.ReadOnly);
	}

	protected void HttpHandlersDetailsView_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
	{
		ShowAlert_DetailsView_ItemInserted(e);

		HttpHandlersGridView.SelectedIndex = -1;
		HttpHandlersGridView.DataBind();
	}

	protected void HttpHandlersDetailsView_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
	{
		ShowAlert_DetailsView_ItemUpdated(e);

		HttpHandlersGridView.SelectedIndex = -1;
		HttpHandlersGridView.DataBind();
	}

	protected void HttpHandlersDetailsView_ItemDeleted(object sender, DetailsViewDeletedEventArgs e)
	{
		ShowAlert_DetailsView_ItemDeleted(e);

		HttpHandlersDetailsView.ChangeMode(DetailsViewMode.Insert);

		HttpHandlersGridView.SelectedIndex = -1;
		HttpHandlersGridView.DataBind();
	}
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="BodyContentPlaceHolder" runat="server">

	<h2>HttpHandlers</h2>

	<div>
		<asp:ObjectDataSource ID="HttpHandlersDetailsViewDataSource" runat="server" 
			DeleteMethod="RemoveHandler" InsertMethod="AddHandler" 
			SelectMethod="GetHandler" 
			TypeName="VioletDevelopmentLaboratory.Net.Web.Configuration.HttpHandlersSectionManager" 
			UpdateMethod="ModifyHandler">
			<DeleteParameters>
				<asp:ControlParameter ControlID="HttpHandlersGridView" Name="index" 
					PropertyName="SelectedIndex" Type="Int32" />
			</DeleteParameters>
			<UpdateParameters>
				<asp:ControlParameter ControlID="HttpHandlersGridView" Name="index" 
					PropertyName="SelectedIndex" Type="Int32" />
				<asp:Parameter Name="path" Type="String" />
				<asp:Parameter Name="type" Type="String" />
				<asp:Parameter Name="verb" Type="String" />
				<asp:Parameter Name="validate" Type="Boolean" />
			</UpdateParameters>
			<SelectParameters>
				<asp:ControlParameter ControlID="HttpHandlersGridView" Name="index" 
					PropertyName="SelectedIndex" Type="Int32" />
			</SelectParameters>
			<InsertParameters>
				<asp:Parameter Name="path" Type="String" />
				<asp:Parameter Name="type" Type="String" />
				<asp:Parameter Name="verb" Type="String" />
				<asp:Parameter Name="validate" Type="Boolean" />
			</InsertParameters>
		</asp:ObjectDataSource>
		<asp:ObjectDataSource ID="HttpHandlersGridViewDataSource" runat="server" 
			SelectMethod="GetHandlers" 
			
			TypeName="VioletDevelopmentLaboratory.Net.Web.Configuration.HttpHandlersSectionManager"></asp:ObjectDataSource>
		<fieldset>
			<asp:DetailsView ID="HttpHandlersDetailsView" runat="server" 
				AutoGenerateRows="False" CellPadding="5" 
				DataSourceID="HttpHandlersDetailsViewDataSource" DefaultMode="Insert" 
				oniteminserted="HttpHandlersDetailsView_ItemInserted" 
				onitemupdated="HttpHandlersDetailsView_ItemUpdated" 
				onitemdeleted="HttpHandlersDetailsView_ItemDeleted">
				<Fields>
					<asp:BoundField DataField="Path" HeaderText="Path" SortExpression="Path" />
					<asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" />
					<asp:BoundField DataField="Verb" HeaderText="Verb" SortExpression="Verb" />
					<asp:CheckBoxField DataField="Validate" HeaderText="Validate" 
						SortExpression="Validate" />
					<asp:CommandField ButtonType="Button" ShowDeleteButton="True" 
						ShowEditButton="True" ShowInsertButton="True" />
				</Fields>
			</asp:DetailsView>
			<asp:GridView ID="HttpHandlersGridView" runat="server" 
				AutoGenerateColumns="False" CellPadding="5" 
				DataSourceID="HttpHandlersGridViewDataSource" 
				onselectedindexchanging="HttpHandlersGridView_SelectedIndexChanging">
				<Columns>
					<asp:CommandField ShowSelectButton="True" />
					<asp:BoundField DataField="Path" HeaderText="Path" SortExpression="Path" />
					<asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" />
					<asp:BoundField DataField="Verb" HeaderText="Verb" SortExpression="Verb" />
					<asp:CheckBoxField DataField="Validate" HeaderText="Validate" 
						SortExpression="Validate" />
				</Columns>
				<SelectedRowStyle BackColor="SkyBlue" />
			</asp:GridView>
		</fieldset>
	</div>
</asp:Content>